<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAgentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('agents')) {
            Schema::create('agents', function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->string('agent_name', 50)->default('')->comment('代理商名称');
                $table->string('manager_name', 50)->default('')->comment('负责人');
                $table->char('mobile', 11)->comment('手机号');
                $table->integer('province_code')->default(0)->comment('省编号');
                $table->integer('city_code')->default(0)->comment('市编号');
                $table->integer('country_code')->default('0')->comment('县编号');
                $table->string('address', 256)->default('')->comment('详细地址');
                $table->string('long_lati', 100)->default('')->comment('经纬度');
                $table->string('domain_name', 50)->default('')->comment('域名');
                $table->string('qualifications', 1024)->default('')->comment('企业资质');
                $table->tinyInteger('audit_status')->default(0)->comment('审核状态（0：待审核，1：审核成功，2：审核失败）');
                $table->string('audit_remark', 512)->default('')->comment('审核备注');
                $table->integer('created_at')->default('0')->comment('创建时间');
                $table->integer('updated_at')->default('0')->comment('更新时间');
            });

            \Illuminate\Support\Facades\DB::statement('ALTER TABLE `caidj_agents` comment "代理商表"');
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('agents');
    }
}
